<?php
include('class/class_connect.php');
include('class/class_page.php');
include('class/abstract/class_paginator.php');
include('class/city_rus.php');
include('class/class_checkGetData.php');
session_start();
if(!isset($_SESSION['login']))
{
	header('location: registr.php');
	exit;
}
foreach($_GET as $key=>$val)
{
	$_GET[$key]=checkGetData::safetyCheck($val);
}
$aCheck=new checkGetData('m');
if($_GET['city'] && $_GET['city']!='')$aCheck->checkCity($_GET['city']);
class myMalls extends paginator
{
	function __construct()
	{
		parent::__construct(15);
	}
	function countRows()
	{
		$aConnect=new connect('m');
		return mysql_num_rows($aConnect->select_all($_GET['city'], "WHERE user='".$_SESSION['login']."'"));
	}
	function pageContent()
	{
		$aConnect=new connect('m');

		$res=$aConnect->select_all($_GET['city'], "WHERE user='".$_SESSION['login']."' LIMIT ".$this->lim.", ".$this->limit."");
		while($this->row=mysql_fetch_array($res))
		{
			if(file_exists('pictures/mallspics/'.$_GET['city'].'/'.$this->row['id'].'.jpg'))
			{
				$img='<img class="subdivPic"
							src="pictures/mallspics/'.$_GET['city'].'/'.$this->row['id'].'.jpg" title="'.$this->row['name'].'"">';
			}
			else
				$img='<img class="subdivPic"
							src="pictures/nologo.jpg" />';
			echo ('
			<div class="myFirmsFirm" align="center">
					<div class="subdivFirmsName">
						<h4 class="name"><a href="mallscabinet.php?city='.$_GET['city'].'&id='.$this->row['id'].'">'.$this->row['name'].'</a></h4>
					</div>
					<a href="mallscabinet.php?city='.$_GET['city'].'&id='.$this->row['id'].'">
						'.$img.'
					</a>
			</div>
			');
		}
	}
}

class aFirmPage extends page
{
	var $row=array();
	var $cityRus;
	function __construct()
	{
		$this->cityRus=new city_rus_class();
		parent::__construct();
	}
	function title()
	{
		echo $_SESSION['login'].' - мои центры';
	}
	function maincontent()
	{
		echo ('
		<div class="route">
			<div class="routeEl">
				<a href="pcabinet.php?city='.$_GET['city'].'">Личный кабинет</a>
			</div>
			<div class="routeEl">
			Мои центры
			</div>
		</div>
		<link rel="stylesheet" type="text/css" href="style/cabinet.css" />
		');
		$aConnect=new connect('main');
		$row=mysql_fetch_array($aConnect->select_all('users', "WHERE login='".$_SESSION['login']."'"));
		$cities=$row['cities'];
		$cities=explode(",", $cities);
		$aConnect->__construct('m');
	  	$obj_city=new city_rus_class();
		echo ('
		<form class="city" method="get" action="" name="city">');

		echo ('
		<select size="1" name="city">');
		for($j=0;$j<count($cities); $j++)
		{
			echo ('
	  		<option value="'.$cities[$j].'"');
	  		if($cities[$j]==$_GET['city'])echo ' selected="selected"';
	  		echo '>'.$obj_city->city_rus_im($cities[$j]).'</option>';
	    }
	    echo ('
	  		</select>');

	  		echo ('
	  		<input type="submit" value="Выбрать">
			</form>
			');
		if(!isset($_GET['city'])or empty($_GET['city']) or $_GET['city']=="")
		{
		$_GET['city']=$cities[0];
		}
		if(isset($_GET['page'])){       //#страницы по умолчанию ноль
		$page=$_GET['page']-1;} else {
		$page=0;}
       $myMalls=new myMalls();

	}
}


$aPage=new aFirmPage();

?>